<?php
defined('_JEXEC') or die('Restricted access');
$user = JFactory::getUser();
//print_r($user);exit();
$i = 1;
$type = intval(JRequest::getVar('type'));
if($type == 1){
	$title = "Katalog";
} else if($type == 2){
	$title = "Biler til salg";
} else if($type == 3){
	$title = "Kommende tvangsauktion";
}
?>
<p><span class="float_left f28"><?php echo $title;?></span><span class="link-login"><a href="index.php?option=com_user&view=user&layout=profile&Itemid=13"><?php if($user->guest==0) {echo  "Min Profil";} ;?></a><a href="index.php?option=com_user&view=login&task=logout&Itemid=13" class="m12l"><?php if($user->guest==0) {echo  "Log ud";};?></a></span></p>
<div class="cb"></div>
<div class="tt m10b"></div>
<?php if($this->cars){?>
<div class="bg_left p5t">
    <div class="box_kato p15t">
        <form action="index.php?option=com_ecommerce&view=cars&type=1-catalogue" method="post" name="carForm" id="carForm">
        <table cellspacing="0" cellpadding="0" border="0" width="100%" class="boder">
          <tbody><tr>
            <td width="3%" class="bg_dark_gray">&nbsp;</td>
            <td width="13%" align="center" class="bg_dark_gray"><strong>Image</strong></td>
            <td width="16%" align="center" class="bg_dark_gray"><strong>Mærke/Model </strong></td>
            <td width="18%" align="center" class="bg_dark_gray"><strong>Placering</strong></td>

            <td width="10%" align="center" class="bg_dark_gray"><strong>Stand </strong></td>
            <td width="16%" align="center" class="bg_dark_gray"><strong>1.Reg. </strong></td>
            <td width="14%" align="center" class="bg_dark_gray"> <strong>Kat.No</strong></td>
          </tr>
          <?php foreach($this->cars as $item){
			  	if($i%2 == 1) $class = 'class="bg_light_gray"';else $class = '';
				if($i > 1) $class1 = 'boder_t';else $class1 = '';
				$type = "";
				if($item->type == 2) $type = "2-biler-til-salg";
				if($item->type == 3) $type = "3-kommende-tvangsauktion";
				$link = "index.php?option=com_ecommerce&view=detail&type=".$type."&id=".$item->id."-".$item->alias;
			?>
          <tr <?php echo $class;?>>
            <td class="<?php echo $class1;?>">
             <?php if($user->guest==0) {  ?>
             <input type="checkbox" id="carid" class="carid" name="carid[]" value="<?php echo $item->id;?>" />
             <?php }?>
             <label for="checkbox"></label>
            </td>
            <td class="boder_l <?php echo $class1;?>"><a href="<?php echo $link;?>"><?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$item->image."&w=90&h=66&zc=1' title='".$item->model."' alt='".$item->model ."' />";?></a></td>

            <td class="boder_l tex_up <?php echo $class1;?>"><a href="<?php echo $link;?>"><?php echo $item->model;?></a></td>
            <td align="center" class="boder_l <?php echo $class1;?>"><?php echo $item->placering;?></td>
            
            
            <td align="center" class="boder_l <?php echo $class1;?>"><?php echo $item->stand;?></td>
            <td align="center" class="boder_l <?php echo $class1;?>"><?php echo $item->register_day;?></td>
            <td align="center" class="boder_l <?php echo $class1;?>"><?php echo $item->katno;?></td>
          </tr>
          
          <?php $i++;}?>
        </tbody></table>
        <div class="space10"></div>
       
	
    <?php if ($user->guest==0){
		//echo '<a href="#" onclick="insert_favourite();"><img src="templates/tpl_automobil/images/bt_add.jpg" /></a>' ;
		} 
    ?>	
        <input type="hidden" name="option" value="com_ecommerce" />
        <input type="hidden" name="task" value="carFavourite" /> 
        </form>
	</div>
</div>
<?php } else {?>
	I øjeblikket ingen bil
<?php }?>
<script>
jQuery(document).ready(function(){
   insert_favourite=function(){
   		if(jQuery("input:checked").length){
			jQuery('#carForm').submit();
		} else {
			$('#alert').html("Vælg et produkt for at føje til listen");
			$('#backoverlay').show();
			$('#show_popup').show();
			return false;
		}
   		
   
    //$("#favorite").click();
	};
});

/*function check_confirm(){

    var c=confirm("you don't sign in yet, you want to sign in?");
    if(c==true)
    {
       window.location="index.php?option=com_user&view=login";

    }
}*/

</script> 
 <script type="text/javascript">
	jQuery(document).ready(function(cash) {
		if(jQuery("#system-message  ul li").html() != null) {
			$('#alert').html(jQuery("#system-message  ul li").html());
			$('#backoverlay').show();
			$('#show_popup').show();	  
		};
		close_popup=function(){		
			var fel=$('#f_focus').html();
			$('#backoverlay').hide();
			$('#show_popup').hide();
			$('#' + fel ).focus();
		};
	});
</script>
